<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>数据类型转换</title>
</head>

<body>
  <script>
    //准备一个变量，赋值为字符串类型内容
    var s1 = '1400'
    console.log(s1)
    console.log(typeof s1)//检测数据类型

    //使用Number（）方法进行一下转换
    var n1 = Number(s1)//字符串数据类型转换数值类型
    console.log(n1)
    console.log(typeof n1)
  </script>

  <script>
    //准备一个变量，赋值为字符串类型内容
    var s1 = '100abc'
    console.log(s1)
    console.log(typeof s1)

    var n1 = Number(s1)
    console.log(n1)
    console.log(typeof n1)//结果为NaN
  </script>

</body>

</html>